package com.itshare.video.mapper;

import com.itshare.video.pojo.po.Advertisement;
import com.itshare.video.pojo.po.AdvertisementExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.session.RowBounds;

public interface AdvertisementMapper {
    long countByExample(AdvertisementExample example);

    int deleteByExample(AdvertisementExample example);

    @Delete({
        "delete from t_advertisement",
        "where advertisement_id = #{advertisementId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer advertisementId);

    @Insert({
        "insert into t_advertisement (company_name, phone, ",
        "banner, advertisement_putting, ",
        "create_time, update_time, ",
        "begin_time, end_time, ",
        "delete_status, create_by, ",
        "update_by, permit_status, ",
        "contact_person_name)",
        "values (#{companyName,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, ",
        "#{banner,jdbcType=VARCHAR}, #{advertisementPutting,jdbcType=INTEGER}, ",
        "#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, ",
        "#{beginTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP}, ",
        "#{deleteStatus,jdbcType=INTEGER}, #{createBy,jdbcType=VARCHAR}, ",
        "#{updateBy,jdbcType=VARCHAR}, #{permitStatus,jdbcType=INTEGER}, ",
        "#{contactPersonName,jdbcType=VARCHAR})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="advertisementId", before=false, resultType=Integer.class)
    int insert(Advertisement record);

    int insertSelective(Advertisement record);

    List<Advertisement> selectByExampleWithRowbounds(AdvertisementExample example, RowBounds rowBounds);

    List<Advertisement> selectByExample(AdvertisementExample example);

    @Select({
        "select",
        "advertisement_id, company_name, phone, banner, advertisement_putting, create_time, ",
        "update_time, begin_time, end_time, delete_status, create_by, update_by, permit_status, ",
        "contact_person_name",
        "from t_advertisement",
        "where advertisement_id = #{advertisementId,jdbcType=INTEGER}"
    })
    @ResultMap("com.itshare.video.mapper.AdvertisementMapper.BaseResultMap")
    Advertisement selectByPrimaryKey(Integer advertisementId);

    int updateByExampleSelective(@Param("record") Advertisement record, @Param("example") AdvertisementExample example);

    int updateByExample(@Param("record") Advertisement record, @Param("example") AdvertisementExample example);

    int updateByPrimaryKeySelective(Advertisement record);

    @Update({
        "update t_advertisement",
        "set company_name = #{companyName,jdbcType=VARCHAR},",
          "phone = #{phone,jdbcType=VARCHAR},",
          "banner = #{banner,jdbcType=VARCHAR},",
          "advertisement_putting = #{advertisementPutting,jdbcType=INTEGER},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "update_time = #{updateTime,jdbcType=TIMESTAMP},",
          "begin_time = #{beginTime,jdbcType=TIMESTAMP},",
          "end_time = #{endTime,jdbcType=TIMESTAMP},",
          "delete_status = #{deleteStatus,jdbcType=INTEGER},",
          "create_by = #{createBy,jdbcType=VARCHAR},",
          "update_by = #{updateBy,jdbcType=VARCHAR},",
          "permit_status = #{permitStatus,jdbcType=INTEGER},",
          "contact_person_name = #{contactPersonName,jdbcType=VARCHAR}",
        "where advertisement_id = #{advertisementId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Advertisement record);
}